# 1 用open打开
# f = open('bzdjs.txt', "r", encoding='utf-8')
# print(f.read())
# 2.用with open
# with open('bzdjs.txt', "r", encoding='utf-8') as file:
#     text = file.read()
# print(text)
# 3.绝对路径
# ff = open(r'C:\Users\Administrator\Desktop/bzdjs.txt', encoding='utf-8')
# print(ff.read())
# 用write写入
# zzz = open('bzdjs1.txt', 'w', encoding='utf-8')
# zzz.write('不知道说啥')

# data = '不知道说啥'
# with open('bzdjs1.txt', 'a', encoding='utf-8') as file:
#    file.write(data)
# 打开excel
df = pd.read_excel(r'C:\Users\Administrator\Desktop\1111.xlsx')
print(df)
# 写文件到excel
a1 = {'名字': 'xiaoming', '年龄':20}
a2 = {'名字': 'xiaozhang', '年龄':20}
a3 = {'名字': 'xiaohong', '年龄':20}
l= [a1,a2,a3]
print(l)
# 变成dataframe
df1 = pd.DataFrame(l)
print(df1)
# 使用pandas函数to_excel()
df1.to_excel('2222.xlsx',index=False)